package com.pyrsana.faith.retreat

import java.util.Date;

import com.pyrsana.contact.Address

class TransportationLeg implements Comparable {
    
    static belongsTo = [retreat:Retreat]
    static hasMany = [rides:Ride]
    
    Location location
    String type
    String notes
    Date meetingDate
    Date dateCreated
    Date lastUpdated

    static constraints = {
        type (size:1..50)
        notes (size:0..2550, nullable:true)
    }

    @Override
    public int compareTo(Object o) {
        if (o instanceof TransportationLeg) {
            if (meetingDate != null) {
                return meetingDate.compareTo(o.meetingDate)
            }
            else {
                return location.name.compareTo(o.location.name)
            }
        }
        else {
            return this.toString().compareTo(o != null? o.toString(): '');
        }
    }
}
